package com.cskaoyan.bean;

import com.cskaoyan.bean.wx.order.WxMarketOrderVo;
import com.github.pagehelper.PageInfo;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 用于查询list时的泛型相应类
 * @param <T> 查询的list的泛型
 */
@NoArgsConstructor
@Data
public class GenericData<T> {
    private Integer total; //总的数据量，没有分页的情况下的数据量
    private Integer pages; //总的页码数
    private Integer limit; //当前页最多的数据量
    private Integer page; //当前页的页码
    private List<T> list; //当前页的数据
    //alt + s

    public static GenericData data(long total,Integer pages,Integer limit,Integer page,List list) {
        GenericData genericData = new GenericData();
        genericData.setTotal((int)total);
        genericData.setPage(page);
        genericData.setPages(pages);
        genericData.setLimit(limit);
        genericData.setList(list);
        return genericData;
    }


    public static GenericData<WxMarketOrderVo> data2(PageInfo pageInfo, List list) {
        GenericData genericData = new GenericData();
        genericData.setTotal((int)pageInfo.getTotal());
        genericData.setPage(pageInfo.getPageNum());
        genericData.setPages(pageInfo.getPages());
        genericData.setLimit(pageInfo.getPageSize());
        genericData.setList(list);
        return genericData;
    }
}
